//
//  ImgLabView.m
//  MyPopStar
//
//  Created by tarena on 16/1/6.
//  Copyright © 2016年 ssnb. All rights reserved.
//

#import "ImgLabView.h"

@interface ImgLabView ()
@property (nonatomic,strong) UIImageView *backgroundView;
@property (nonatomic,strong) UILabel *titleLab;
@property (nonatomic,assign) NSInteger nub;

@end
@implementation ImgLabView

-(instancetype)initWithBackgroundImg:(UIImage *)img andTitle:(NSInteger )number{
    if (self = [super init]) {
        [self mInitImg:img];
        self.nub = number;
        [self mInitTitle];
    }
    return self;
}
-(void)mInitImg:(UIImage *)img{
    self.backgroundView = [[UIImageView alloc]init];
    self.backgroundView.image = img;
    [self addSubview:self.backgroundView];
    [self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
}

-(void)mInitTitle{
    self.titleLab = [[UILabel alloc]init];
    self.titleLab.textColor =[UIColor whiteColor];
    self.titleLab.text = self.titleStr;
    self.titleLab.textAlignment=NSTextAlignmentCenter;
    [self addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
}

-(NSString*)titleStr{
    return [NSString stringWithFormat:@"%ld",self.nub];
}
-(void)ChangeTitle:(NSInteger)number{
    self.nub = number;
    self.titleLab.text=self.titleStr;
}
mdealloc
@end
